<template>
<div class="search">
    <!-- 下拉菜单 -->
    <van-dropdown-menu>
        <!-- disabled禁用，根据实际需求写 -->
        <van-dropdown-item  disabled title="全部" />
        <van-dropdown-item v-model="value1" :options="option1" title="价格" @change="changePrice"/>
        <van-dropdown-item v-model="value2" :options="filterCategory" title="分类" @change="changeKind"/>
    </van-dropdown-menu>
</div>
</template>

<script>
export default {
name: 'Dropmenu',
data() {
return {
    value1: 'desc',
    // value2: 0,
    option1: [
    { text: '价格由高到低', value: 'desc'},
    { text: '价格由低到高', value: 'asc' },
    ],
    // option2: [
    // { text: '默认排序', value: 'a' },
    // { text: '好评排序', value: 'b' },
    // { text: '销量排序', value: 'c' },
    // ],
}
},
props:['filterCategory'],
components: {

},
methods: {
    changePrice(val){
        // 点击切换价格
        // console.log(val);
        // 通过子传父的方式，将val数据传递给search
        this.$emit('transfer',val)
    },
    changeKind(val){
        // 点击切换分类
        // console.log(val);
        this.$emit('transfer1',val)
    }
},
created() {

},
computed:{
    value2:{
        get(){
            let id;
            this.filterCategory.forEach(item=>{
                if(item.checked){
                    id = item.value
                }
            })
            return id
        },
        set(val){

        }        
    }
}
}
</script>

<style lang='less' scoped>
// .search{

// }
</style>